-- ***********************************************************************************************
-- GETDELETECONFLICT Stored Procedures for the list of tables mentioned in the Initialize file
--------------------------------------------------------------------------------------------------

--TABLE NAME: CustomerContact    STORED PROCEDURE NAME: Sales.sync_sp_CustomerContact_GetDeleteConflict

use [SyncSamplesDb_ChangeTracking_Custom]

if object_id(N'Sales.sync_sp_CustomerContact_GetDeleteConflict', 'P') is not null
	drop procedure Sales.sync_sp_CustomerContact_GetDeleteConflict
GO

	create procedure Sales.sync_sp_CustomerContact_GetDeleteConflict(
		@sync_last_received_anchor bigint
        ,@CustomerId uniqueidentifier
	,@PhoneType nvarchar
	)        
as
	SELECT		CT.CustomerId
				, CT.PhoneType
				, CT.SYS_CHANGE_CONTEXT
				, CT.SYS_CHANGE_VERSION 
	FROM		CHANGETABLE(CHANGES [SyncSamplesDb_ChangeTracking_Custom].[Sales].[CustomerContact], @sync_last_received_anchor) AS CT
	WHERE		CT.SYS_CHANGE_OPERATION = 'D'
				AND CT.CustomerId = @CustomerId
				AND CT.PhoneType = @PhoneType
				
GO

-------------------------------------------END------------------------------------------------------------------
	
